package com.sxpi.order.mode.event.message;

import com.sxpi.order.mode.event.OrderEvent;
import com.sxpi.order.feign.api.MessageOrderFeginApi;
import com.sxpi.order.vo.MessageOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @Author: 董伟豪
 * @Date: 2022/10/28 20:30
 */
@Component
public class MessageListener implements ApplicationListener<OrderEvent> {

    @Autowired
    private MessageOrderFeginApi messageOrderFeginApi;

    @Override
    public void onApplicationEvent(OrderEvent event) {
        messageSave(event.getMessageOrderVo());
    }

    private void messageSave(MessageOrderVo messageOrderVo){
        messageOrderFeginApi.saveMessageOrder(messageOrderVo);
    }
}
